package std

import (
	"database/sql"
	"fmt"

	"rdbmsx/config"
	//conn, err := sql.Open("clickhouse", fmt.Sprintf("clickhouse://127.0.0.1:9001,127.0.0.1:9002,%s:%d/%s?username=%s&password=%s&dial_timeout=10s&connection_open_strategy=round_robin&debug=true&compress=lz4",
)

func ConnectSettings() error {
	conn, err := sql.Open("clickhouse", fmt.Sprintf("clickhouse://%s/%s?username=%s&password=%s&dial_timeout=10s&connection_open_strategy=round_robin&debug=true&compress=lz4",
		config.ClickHouseHost, config.Database, config.ClickHouseUser, config.ClickHousePassword))
	if err != nil {
		return err
	}

	return conn.Ping()
}
